import { _decorator } from 'cc';
import { Key } from '../frame/common/Enums';
import { aa } from '../frame/FrameCore';

class RewardSys {

    showCashView(value = 2000){
        if(aa.global.isOpen) return;
        aa.global.isOpen = true;
        aa.ui.prompt({
            tittle:"任务奖励",
            content:"金币x"+value,
            confirmCB:this.addCash.bind(this,value)
        })
        aa.global.isOpen = false;

    }
    showDiamondView(value=200){
        if(aa.global.isOpen) return;
        aa.ui.prompt({
            tittle:aa.locale.t("ui.diamond"),
            content:aa.locale.t("prompt.diamond"),
            confirmCB:this.addDiamond.bind(this,value)
        })
    }

    showChestView(value = 20){
        aa.ui.prompt({
            tittle:aa.locale.t("ui.chest"),
            content:aa.locale.t("prompt.chest"),
            confirmCB:this.addChest.bind(this,value)
        })
    }
    addChest(value = 20){
        aa.data.addCurrency(Key.Chest, value);
    }

    addCash(value = 2000) {
        aa.data.addCurrency(Key.Cash, value);
    }
    addDiamond(value = 200) {
        aa.data.addCurrency(Key.Diamond, value);

    }
  
}

const reward = new RewardSys;
export default reward;

